/**
 * @author bbrison
 * @author jprieur
 * @created 05/06/07
 */
package kernel;

import communication.thirdLayer.*;
import java.util.*;

public class DataSensorSimulator extends DataSimulator {
    
    public SensorRouting _sensorRouting;
    public static SensorRouting ROUTING_DEF = new DirectedDiffusion();
    public final static String ROUTING_PACK = "communication.thirdLayer";
    public final static String ROUTING_INTER = "SensorRouting";
    
    public DataSensorSimulator(int mode) {
	super(mode);
	setRouting(ROUTING_DEF);
    }

    public DataSensorSimulator(String name, 
                               String description,
			       int mode, 
			       double duration, 
			       String resultFile,
			       SensorRouting sr //, 
			       //     Vector<DataSensorNetwork> datasnet, 
			       //			       Vector<DataSink> sinks
			       )   {
	super(name,description,mode,duration,resultFile);
	setRouting(sr);
    }

    public boolean setRouting(String s){
	try{
	    Class routingClass = Class.forName(ROUTING_PACK + "." + s);
	     SensorRouting algo = (SensorRouting)(routingClass.newInstance());
	    return setRouting(algo);
	}catch(Exception e){
	    e.printStackTrace();
	    setRouting(ROUTING_DEF);
	    return false;
	}	
    }

    public boolean setRouting(SensorRouting sr) {
	_sensorRouting = sr;
	return true;
    }

    public SensorRouting getRouting() {
	return _sensorRouting;
    }

}
